import { createApp } from "vue";
import Message from "@/components/Message.vue"
export type MessageType = "success" | "error" | "default";
// 用函数来创建组件
const createMessage = (message: string, type: MessageType, timeout = 2000) => {
  const messageInstance = createApp(Message, { message, type })
  const node = document.createElement('div')
  document.body.appendChild(node)
  messageInstance.mount(node)
  setTimeout(() => {
    messageInstance.unmount()
    document.body.removeChild(node)
  }, 2000);
}

export default createMessage